<?php

declare(strict_types=1);

namespace App\WorkEmployee\Controller\Dashboard;

use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middleware;
use Hyperf\HttpServer\Annotation\Middlewares;
use Hyperf\HttpServer\Annotation\RequestMapping;
use App\Common\Middleware\DashboardAuthMiddleware;
use App\WorkEmployee\QueueService\EmployeeApply;
use App\WorkDepartment\QueueService\DepartmentApply;
use Base\Controller\AbstractController;

/**
 * 同步企业成员 - 页面.
 * @Controller
 */
class SyncEmployee extends AbstractController
{
    /**
     * @var EmployeeApply
     */
    protected $employeeApply;

    /**
     * @var DepartmentApply
     */
    protected $departmentApply;

    /**
     * @Middlewares({
     *     @Middleware(DashboardAuthMiddleware::class)
     * })
     * @RequestMapping(path="/dashboard/workEmployee/synEmployee", methods="POST")
     */
    public function handle()
    {
        $params['corpId'] = $this->request->input('userInfo.corp_id');
        $params['tenantId'] = $this->request->input('userInfo.tenant_id');
        $params['userId'] = $this->request->input('userInfo.user_id');
        $params['deptId'] = $this->request->input('userInfo.dept_id');
        $corpIds[0] = $this->request->input('userInfo.corp_id');
        //同步成员信息
        make(EmployeeApply::class)->handle($corpIds,$params);
        //同步部门
        make(DepartmentApply::class)->handle($corpIds,$params);
    }
}
